package com.macro.mall.demo.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
public class InitEsRes {

    @Value("${es.host:60.204.203.152}")
    private String host;
    @Value("${es.port:8082}")
    private int port;
    @Value("${es.scheme:mall-es}")
    private String scheme;

    @Bean
    public RestHighLevelClient restHighLevelClient(){
        return new RestHighLevelClient(
                RestClient.builder(new HttpHost(host,port,scheme))
        );
    }
}
